home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 202 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. From: krotoff@such.srcc.msu.su (Alexander Krotoff)
  2. Message-ID: <4eo2g5$7s3@boy.nmd.msu.ru>
  3. X-Original-Date: 31 Jan 1996 18:39:49 +0300
  4. Path: in2.uu.net!bounce-back
  5. Date: 01 Feb 96 01:51:12 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Incompatibility C++ <-> ANSI-C
  9. Organization: Research Computer Center, Moscow State University
  10. References: <4ekpnj$h7q@fsuj01.rz.uni-jena.de>
  11. X-Comment-To: mkt@isun04.inf.uni-jena.de
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMRAcnuEDnX0m9pzZAQF/iQGAm0apZ0nukNw5j/FFwMOmPlMPw2LEI4mS
  14.     mSuJ/sAr7CfyqvO6Zw2Fb8aN9oy5brS7
  15.     =okMn
  16.  
  17. mkt@isun04.inf.uni-jena.de wrote:
  18. > Does the operator ?: an itegral promotion on its
  19. > second and third operand in C++?
  20. > I cannot find the answer in the ARM. (I think it says: no)
  21. > Consider this:
  22. > char x, y;
  23. > Which type has the following expression:
  24. > (a ? x : y)
  25. > In ANSI-C the type is clearly an 'int' (or 'unsigned').
  26. > But the type in C++ is 'char'???
  27. > Even different compilers have different results!
  28. > (Borland 3.1: 'char', SPARCompiler 4.0: 'int')
  29.  
  30. I think Borland is right.
  31.  
  32. Working papers (5.16  Conditional operator) says:
  33.  
  34. 2 If the second and the third operands are lvalues  and  have  the  same
  35.   type  (before  any  implicit  conversions), the result is an lvalue of
  36.   that  type. 
  37.  
  38. Since both second and third operans are lvalues no implicit
  39. conversion will be performed.
  40.  
  41. Almost the same I found in the ARM (5.16, Russian edition).
  42.  
  43. --
  44. Alexander N. Krotoff        krotoff@such.srcc.msu.su
  45. Research Computer Center    tel: +7(095)939-2638
  46. Moscow State University        fax: +7(095)939-4430
  47. ---
  48. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  49.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  50.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  51.